home *** CD-ROM | disk | FTP | other *** search
/ Practical Internet Web Designer 86 / PIWD86.iso / pc / contents / dreamweaver / software / dwmx2004.exe / Disk1 / data1.cab / Configuration_En / Commands / Create Component.js < prev    next >
Encoding:
JavaScript  |  2003-09-05  |  68.7 KB  |  2,585 lines

  1. // Copyright 2002, 2003 Macromedia, Inc. All rights reserved.
  2.  
  3. // *************** GLOBALS VARS *****************
  4.  
  5.  
  6. var HELP_DOC = MM.HELP_cmdCreateComponent;
  7.  
  8. var SECTION_LIST = "";
  9. var LABEL_ACCESSES = new Array ("private", "package", "public", "remote");
  10. var DEFAULT_ACCESS = "public";
  11. var LABEL_TYPES =  new Array(
  12.   "any","array","binary","boolean","date","GUID","numeric",
  13.   "query","string","struct","UUID","variableName");
  14.   
  15. var LABEL_PARENT_CFCS = new Array();
  16. var LABEL_CFC_ROOTS = new Array();
  17.   
  18. var COMPONENT_INFO = "";
  19. var FILE_DIR = "";
  20.  
  21. var TEMPLATE_URL = dw.getConfigurationPath() + "/CFComponentTemplate.cfc"
  22. var errorCount = 0;
  23.  
  24. var FORWARD_SLASH = "/";
  25. var BACK_SLASH = "\\"
  26.  
  27.  
  28. // TODO:
  29. //   Implement validation
  30. //   Remove localizable strings
  31.  
  32.  
  33. // ******************* API **********************
  34.  
  35. //--------------------------------------------------------------------
  36. // FUNCTION:
  37. //   commandButtons
  38. //
  39. // DESCRIPTION:
  40. //   The list of buttons to display on the right of the dialog,
  41. //   along with the functions to call when they are pressed.
  42. //
  43. // ARGUMENTS:
  44. //   none
  45. //
  46. // RETURNS:
  47. //   javascript array
  48. //--------------------------------------------------------------------
  49.  
  50. function commandButtons()
  51. {
  52.     return new Array(MM.BTN_OK,     "okClicked();",
  53.                    MM.BTN_Cancel, "cancelClicked()",
  54.                    MM.BTN_Help,   "displayHelp();");
  55. }
  56.  
  57.  
  58. //--------------------------------------------------------------------
  59. // FUNCTION:
  60. //   canAcceptCommand
  61. //
  62. // DESCRIPTION:
  63. //   Called to determine if the command can be displayed.
  64. //
  65. // ARGUMENTS:
  66. //   none
  67. //
  68. // RETURNS:
  69. //   boolean - true if the dialog can be launched
  70. //--------------------------------------------------------------------
  71.  
  72. function canAcceptCommand()
  73. {
  74.   return ((dw.getDocumentDOM() && dw.getDocumentDOM().getParseMode() == 'html') &&
  75.  (((dw.getFocus() == 'document') 
  76.     && (dreamweaver.getDocumentDOM("document").body)) ||
  77.     (dw.getFocus(true) == 'html' || dw.getFocus() == 'textView')) );
  78. }
  79.  
  80.  
  81. //--------------------------------------------------------------------
  82. // FUNCTION:
  83. //   okClicked
  84. //
  85. // DESCRIPTION:
  86. //   Called when the OK button is pressed.  Saves the Component.
  87. //
  88. // ARGUMENTS:
  89. //   none
  90. //
  91. // RETURNS:
  92. //   nothing
  93. //--------------------------------------------------------------------
  94.  
  95. function okClicked()
  96. {
  97.   T.finish();
  98.   
  99.   var errMsg = COMPONENT_INFO.validate();
  100.   
  101.   if (!errMsg)
  102.   {
  103.     errMsg = saveToFile();
  104.   }
  105.   
  106.   if (errMsg)
  107.   {
  108.     var fullMsg = MSG_Error_Header + "\r\n" +
  109.       "==================================================\r\n\r\n" +
  110.         errMsg;
  111.     // reset the _errorCount
  112.     errorCount = 0;
  113.     alert(fullMsg);
  114.     //alert(errMsg);
  115.   }
  116.   else if( errMsg == "" )
  117.   { // null == declined creating subdirectory    
  118.     window.close();
  119.   }
  120. }
  121.  
  122.  
  123. //--------------------------------------------------------------------
  124. // FUNCTION:
  125. //   cancelClicked
  126. //
  127. // DESCRIPTION:
  128. //   Called when the Cancel button is pressed.  Dismiss the dialog.
  129. //
  130. // ARGUMENTS:
  131. //   none
  132. //
  133. // RETURNS:
  134. //   nothing
  135. //--------------------------------------------------------------------
  136.  
  137. function cancelClicked()
  138. {
  139.   window.close();    
  140. }
  141.  
  142.  
  143. //--------------------------------------------------------------------
  144. // FUNCTION:
  145. //   displayHelp
  146. //
  147. // DESCRIPTION:
  148. //   Displays the built-in Dreamweaver help.
  149. //
  150. // ARGUMENTS:
  151. //   none
  152. //
  153. // RETURNS:
  154. //   nothing
  155. //--------------------------------------------------------------------
  156.  
  157. function displayHelp()
  158. {
  159.   // Replace the following call if you are modifying this file for your own use.
  160.   dwscripts.displayDWHelp(HELP_DOC);
  161. }
  162.  
  163.  
  164. // ***************** LOCAL FUNCTIONS  ******************
  165.  
  166. //--------------------------------------------------------------------
  167. // FUNCTION:
  168. //   initializeUI
  169. //
  170. // DESCRIPTION:
  171. //   Prepare the dialog and controls for user input
  172. //
  173. // ARGUMENTS:
  174. //   none
  175. //
  176. // RETURNS:
  177. //   nothing
  178. //--------------------------------------------------------------------
  179.  
  180. function initializeUI()
  181. {
  182.   // fill the array before the component section is initialized
  183.   LABEL_PARENT_CFCS = getParentCfcs();
  184.  
  185.   LABEL_CFC_ROOTS = getCfcRoots();
  186.   COMPONENT_INFO = new ComponentInfo();
  187.  
  188.   SECTION_LIST = new ListControl("section");  
  189.   SECTION_LIST.setAll(LABEL_SECTIONS, VALUE_SECTIONS);  
  190.   SECTION_LIST.setIndex(0);
  191.  
  192.   //Initialize the TabControl.  (Pass in the prefix used for the tab layers)
  193.   T = new TabControl('Tab');
  194.   //Add tab pages.   (Pass the layer name, and the page object)
  195.   T.addPage("componentSection", new ComponentsPage());
  196.   T.addPage("propertiesSection", new PropertiesPage());
  197.   T.addPage("methodsSection", new MethodsPage());
  198.   T.addPage("parametersSection", new ParametersPage());
  199.  
  200.   //Initialize the display.  Start with the selected page
  201.   T.start(SECTION_LIST.getValue());
  202.  
  203.   MM.CFCfileToOpen = "";
  204. }
  205.  
  206. //--------------------------------------------------------------------
  207. // FUNCTION:
  208. //   updateUI
  209. //
  210. // DESCRIPTION:
  211. //   Called by the main UI components to respond to events
  212. //
  213. // ARGUMENTS:
  214. //   theItemName - string - the name of the form control which
  215. //     generated the event
  216. //
  217. // RETURNS:
  218. //   nothing
  219. //--------------------------------------------------------------------
  220.  
  221. function updateUI(theItemName)
  222. {
  223.   if (theItemName == "section")
  224.   {
  225.     T.showPage(SECTION_LIST.getValue())
  226.   }
  227. }
  228.  
  229.  
  230. //--------------------------------------------------------------------
  231. // FUNCTION:
  232. //   saveToFile
  233. //
  234. // DESCRIPTION:
  235. //   Saves the current settings to the component file
  236. //
  237. // ARGUMENTS:
  238. //   none
  239. //
  240. // RETURNS:
  241. //   string - error message if any
  242. //--------------------------------------------------------------------
  243.  
  244. function saveToFile()
  245. {
  246.   var errMsg = "";
  247.   
  248.   // Get the file name
  249.   fileURL = getFileURL();
  250.  
  251.   // fileExists returns true for ""?
  252.   if ("" != fileURL)
  253.   {
  254.     if ( dwscripts.fileExists(fileURL))
  255.       {
  256.       // display confirmation message
  257.       if (!confirm(MSG_OverwriteExisting))
  258.       {
  259.         //return MSG_DeclinedOverwrite;
  260.         return null; // do not show error message if user doesn't want to overwrite
  261.       }
  262.     }
  263.   } else {
  264.     return null; // user declined creating subfolders?
  265.   }
  266.  
  267.   var fileOutput = new Array();
  268.   fileOutput.push( dwscripts.sprintf(LABEL_FileGeneratedBy, dw.appName, dw.appVersion, new Date()) );
  269.   fileOutput.push(COMPONENT_INFO.serialize());
  270.   
  271.   //alert(fileOutput.join(""));
  272.  
  273.   if (!dwscripts.setFileContents(fileURL, fileOutput.join("")))
  274.   {
  275.     errMsg = dwscripts.sprintf(MSG_FileWriteError,fileURL);
  276.   }
  277.   else
  278.   {
  279.      //  We don't want to actually open the CFC file here.  At first blush this might seem
  280.      //  like the right thing to do.  However, there is a problem if we try to do so.  That
  281.      //  problem concerns some very complicated stuff regarding edit ops and when to
  282.      //  suspend/continue them.  It is too complicated to explain here.  Suffice it to say
  283.      //  that the better way to do this is to set a variable here and let the caller
  284.      //  (in CFCs.js) do the actual opening of the document.
  285.  
  286.      MM.CFCfileToOpen = fileURL;
  287.   }
  288.   
  289.   return errMsg;
  290. }
  291.  
  292.  
  293. //--------------------------------------------------------------------
  294. // FUNCTION:
  295. //   saveToTemplate
  296. //
  297. // DESCRIPTION:
  298. //   Saves the current settings to a template
  299. //
  300. // ARGUMENTS:
  301. //   none
  302. //
  303. // RETURNS:
  304. //   string - error message if any
  305. //--------------------------------------------------------------------
  306.  
  307. function saveToTemplate()
  308. {
  309.   var errMsg = "";
  310.   
  311.   var fileOutput = new Array();
  312.   fileOutput.push( dwscripts.sprintf(LABEL_FileGeneratedBy, dw.appName, dw.appVersion, new Date()) );
  313.   fileOutput.push(COMPONENT_INFO.serialize());
  314.  
  315.   //alert(fileOutput.join(""));
  316.  
  317.   if (!dwscripts.setFileContents(TEMPLATE_URL, fileOutput.join("")))
  318.   {
  319.    errMsg = dwscripts.sprintf(MSG_FileWriteError,TEMPLATE_URL);
  320.   }
  321.   else
  322.   {
  323.     alert(MSG_TemplateSaved);
  324.   }
  325.   
  326.   return errMsg;
  327. }
  328.  
  329.  
  330. //--------------------------------------------------------------------
  331. // FUNCTION:
  332. //   loadFromTemplate
  333. //
  334. // DESCRIPTION:
  335. //   Reads in the component setting from a template
  336. //
  337. // ARGUMENTS:
  338. //   none
  339. //
  340. // RETURNS:
  341. //   boolean
  342. //--------------------------------------------------------------------
  343.  
  344. function loadFromTemplate()
  345. {
  346.   var retVal = false;
  347.   
  348.   if (dwscripts.fileExists(TEMPLATE_URL))
  349.   {  
  350.     var fileContents = dwscripts.getFileContents(TEMPLATE_URL);
  351.  
  352.     if (fileContents)
  353.     {
  354.       var retVal = COMPONENT_INFO.deserialize(fileContents);
  355.     }
  356.  
  357.     if (!retVal)
  358.     {
  359.       alert("ERROR parsing template file");
  360.     }
  361.   }
  362.   else
  363.   {
  364.     // alert template does not exist
  365.   }
  366.   
  367.   return retVal;
  368. }
  369.  
  370.  
  371. //--------------------------------------------------------------------
  372. // FUNCTION:
  373. //   getFileURL
  374. //
  375. // DESCRIPTION:
  376. //   Returns the full URL for the current component file
  377. //
  378. // ARGUMENTS:
  379. //   none
  380. //
  381. // RETURNS:
  382. //   string
  383. //--------------------------------------------------------------------
  384.  
  385. function getFileURL()
  386. {
  387.   var retVal = "";
  388.   
  389.   if (FILE_DIR && COMPONENT_INFO.name)
  390.   {
  391.     if( normalizedDirectory() )
  392.     {
  393.       retVal = FILE_DIR + COMPONENT_INFO.name + ".cfc";
  394.     }
  395.     
  396.   }
  397.   
  398.   return retVal;
  399. }
  400.  
  401. //--------------------------------------------------------------------
  402. // FUNCTION:
  403. //   normalizedDirectory
  404. //
  405. // DESCRIPTION:
  406. //   - converts the FILE_DIR to Local URL
  407. //   - appends BACK_SLASH or FORWARD_SLASH as necessary
  408. //   - confirms creation of non-existent subdirectories
  409. //
  410. // ARGUMENTS:
  411. //   none
  412. //
  413. // RETURNS:
  414. //   boolean if nothing went wrong
  415. //--------------------------------------------------------------------
  416.  
  417. function normalizedDirectory() {
  418.   var originalDirectory = FILE_DIR;
  419.   var directory = dwscripts.filePathToLocalURL(FILE_DIR);
  420.   var lastChar = directory.charAt(directory.length-1);
  421.  
  422.   if( lastChar != FORWARD_SLASH && lastChar != BACK_SLASH )
  423.   {
  424.     // attempt to find the appropriate slash to use
  425.     if( directory.indexOf(BACK_SLASH) > -1 )
  426.     {
  427.       directory += BACK_SLASH;
  428.     } 
  429.     else
  430.     {
  431.       directory += FORWARD_SLASH;
  432.     }
  433.   }
  434.   FILE_DIR = directory;
  435.  
  436.   // confirm with the user to create non-existent directories
  437.   if( !DWfile.exists(directory) )
  438.   {
  439.     if( confirm( dwscripts.sprintf(MSG_CreateDirectory, originalDirectory) ) )
  440.     {
  441.      //DWfile.createFolder(compFileDir);
  442.       return createFolder(directory);
  443.     }
  444.     else
  445.     {
  446.       return false;
  447.     }
  448.   }
  449.   return true;
  450. }
  451.  
  452. //--------------------------------------------------------------------
  453. // FUNCTION:
  454. //   createFolder
  455. //
  456. // DESCRIPTION:
  457. //   - cut and pasted from Configuration/WebServices/ProxyGenerators/DefaultProxyGen.js
  458. //   - doesn't work with multiple subdirectories when using UNC path of \\compname\compdir
  459. //
  460. // ARGUMENTS:
  461. //   folderURL - the full folder URL
  462. //
  463. // RETURNS:
  464. //   boolean if nothing went wrong
  465. //--------------------------------------------------------------------
  466. function createFolder(folderURL)
  467. {
  468.   var fileFolderURL = MMNotes.localURLToFilePath(folderURL);
  469.   if (fileFolderURL)
  470.   {
  471.     var start = 0, index = -1, nextindex = -1, folder;
  472.     while (index < fileFolderURL.length)
  473.     {
  474.       index = ((fileFolderURL.indexOf("\\", start)) || (fileFolderURL.indexOf("/", start)));
  475.       if (index != -1)
  476.       {
  477.         folder = fileFolderURL.substr(0, index);
  478.         if (!DWfile.exists(MMNotes.filePathToLocalURL(folder)))
  479.         {
  480.           if (DWfile.createFolder(MMNotes.filePathToLocalURL(folder)))
  481.           {
  482.             start = index + 1;
  483.           }
  484.           else  
  485.             return false;
  486.         }
  487.         else
  488.         {
  489.           start = index + 1;
  490.         }
  491.       } // index != -1
  492.       else
  493.       {
  494.         folder = fileFolderURL;
  495.         if (!DWfile.exists(MMNotes.filePathToLocalURL(folder)))
  496.         {
  497.           if (!DWfile.createFolder(MMNotes.filePathToLocalURL(folder)))
  498.             return false;
  499.           else
  500.             return true;  
  501.         }
  502.         else
  503.           break;  
  504.       }
  505.     } // while
  506.   }
  507.   return true;
  508. }
  509.  
  510. //--------------------------------------------------------------------
  511. // FUNCTION:
  512. //   getUniqueName
  513. //
  514. // DESCRIPTION:
  515. //   Returns a unique name based on the given prefix, and an array
  516. //   of names that already exist.
  517. //
  518. //   If the label is unique, then it is returned with no suffix.
  519. //   If it is not unique, then the next unique name is found.
  520. //
  521. // ARGUMENTS:
  522. //   prefix - string - the base name to use
  523. //   arrayToSearch - array of objects with name property - the array
  524. //     of objects to search for duplicate names
  525. //
  526. // RETURNS:
  527. //   string
  528. //--------------------------------------------------------------------
  529.  
  530. function getUniqueName(prefix, arrayToSearch)
  531. {
  532.   var retVal = prefix;
  533.   var count = 0;
  534.   
  535.   if (arrayToSearch != null && arrayToSearch.length > 0)
  536.   {
  537.     var matchFn = new Function("object,searchValue", "return (object.name == searchValue);");
  538.  
  539.     while (dwscripts.findInArray(arrayToSearch,retVal,matchFn) != -1)
  540.     {
  541.       count++;
  542.       retVal = prefix + count.toString();
  543.     }
  544.   }
  545.   
  546.   return retVal;
  547. }
  548.  
  549.  
  550. //--------------------------------------------------------------------
  551. // FUNCTION:
  552. //   containsInvalidChars
  553. //
  554. // DESCRIPTION:
  555. //   Returns true if the given string contains invalid characters
  556. //
  557. // ARGUMENTS:
  558. //   str - string - the string to check
  559. //
  560. // RETURNS:
  561. //   boolean
  562. //--------------------------------------------------------------------
  563.  
  564. function containsInvalidChars(str)
  565. {
  566.   var retVal = false;
  567.   
  568.   if (str) 
  569.   {
  570.     var regExp = /[^\w\d]/g; // new in JS 1.5, \w will support special characters 
  571.     
  572.     retVal = (str.search(regExp) != -1);
  573.   }
  574.   
  575.   return retVal;
  576. }
  577.  
  578.  
  579. //--------------------------------------------------------------------
  580. // FUNCTION:
  581. //   createFolders
  582. //
  583. // DESCRIPTION:
  584. //   Recursively creates folders for the given file URL
  585. //
  586. // ARGUMENTS:
  587. //   fileURL - string - the URL path of the folder to create
  588. //
  589. // RETURNS:
  590. //   boolean - true if successfull
  591. //--------------------------------------------------------------------
  592.  
  593. function createFolders(fileURL)
  594. {
  595.   var retVal = true;
  596.   
  597.   if (!dwscripts.fileExists(fileURL))
  598.   {
  599.     var parentURL = dwscripts.getAbsoluteParentURL();
  600.     
  601.     if (createFolders(parentURL))
  602.     {
  603.       retVal = dwscripts.createFolder(fileURL);
  604.     }
  605.     else
  606.     {
  607.       retVal = false;
  608.     }
  609.   }
  610.   
  611.   return retVal;
  612. }
  613.  
  614.  
  615.  
  616. //--------------------------------------------------------------------
  617. // CLASS:
  618. //   ComponentInfo
  619. //
  620. // DESCRIPTION:
  621. //   This class represents the information about a component
  622. //
  623. // PUBLIC PROPERTIES:
  624. //
  625. //   name
  626. //   displayName
  627. //   description
  628. //   parent
  629. //     
  630. //   properties
  631. //   methods
  632. //
  633. //   fileDir    
  634. //
  635. // PUBLIC FUNCTIONS:
  636. //
  637. //   serialize()
  638. //   validate()
  639. //   getFileURL()
  640. //
  641. //--------------------------------------------------------------------
  642.  
  643. function ComponentInfo()
  644. {
  645.   this.name = "";
  646.   this.displayName = "";
  647.   this.description = "";
  648.   this.parent = "";
  649.   
  650.   this.properties = new Array();  // array of property info
  651.   
  652.   this.methods = new Array();
  653. }
  654.  
  655. ComponentInfo.prototype.serialize = ComponentInfo_serialize;
  656. ComponentInfo.prototype.serializeToTagEdit = ComponentInfo_serializeToTagEdit;
  657. ComponentInfo.prototype.deserialize = ComponentInfo_deserialize;
  658. ComponentInfo.prototype.validate = ComponentInfo_validate;
  659.  
  660.  
  661. function ComponentInfo_serialize()
  662. {
  663.   var componentTag = this.serializeToTagEdit();
  664.   
  665.   componentTag.format("\t");
  666.   
  667.   return componentTag.getOuterHTML();
  668. }
  669.  
  670.  
  671. function ComponentInfo_serializeToTagEdit(tagToSet)
  672. {
  673.   var componentTag = null;
  674.   if (tagToSet)
  675.   {
  676.     componentTag = tagToSet;
  677.   }
  678.   else
  679.   {    
  680.     componentTag = new TagEdit("<cfcomponent></cfcomponent>");
  681.   }
  682.   
  683.   // componentTag.setAttribute("name", this.name);
  684.   if (this.displayName)
  685.   {
  686.     componentTag.setAttribute("displayName", this.displayName);
  687.   }
  688.   if (this.description)
  689.   {
  690.     componentTag.setAttribute("hint", this.description);
  691.   }
  692.   if (this.parent)
  693.   {
  694.     componentTag.setAttribute("extends", this.parent);
  695.   }
  696.   
  697.   var childNodes = new Array();
  698.   
  699.   for (var i=0; i < this.properties.length; i++)
  700.   {
  701.     childNodes.push(this.properties[i].serializeToTagEdit());
  702.   }
  703.   
  704.   for (var i=0; i < this.methods.length; i++)
  705.   {
  706.     childNodes.push(this.methods[i].serializeToTagEdit());
  707.   }
  708.  
  709.   componentTag.setChildNodes(childNodes);
  710.  
  711.   return componentTag;  
  712. }
  713.  
  714.  
  715. function ComponentInfo_deserialize(tagSource)
  716. {
  717.   var retVal = false;
  718.  
  719.   var componentTag = null;
  720.   
  721.   if (typeof tagSource == "string")
  722.   {
  723.     // use the tag edit class to read out the properties
  724.     var tagList = TagEdit.parseString(tagSource);
  725.  
  726.     // set the componentTag
  727.     var componentTag = null;
  728.     if (tagList)
  729.     {
  730.       for (var i=0; i < tagList.length; i++)
  731.       {
  732.         if (tagList[i].getTagName() == "CFCOMPONENT")
  733.         {
  734.           componentTag = tagList[i];
  735.           break;
  736.         }
  737.       }
  738.     }
  739.   }
  740.   else
  741.   {
  742.     componentTag = tagSource;
  743.   }
  744.   
  745.   
  746.     
  747.   if (componentTag)
  748.   {
  749.     retVal = true;
  750.     
  751.     this.name = componentTag.getAttribute("name");
  752.     this.displayName = componentTag.getAttribute("displayName");
  753.     this.description = componentTag.getAttribute("hint");
  754.     this.parent = componentTag.getAttribute("parentDescriptor");
  755.     
  756.     var childNodes = componentTag.getChildNodes();
  757.     
  758.     this.properties = new Array();
  759.     this.methods = new Array();
  760.     
  761.     // get the properties and methods
  762.     for (var i=0; i < childNodes.length; i++)
  763.     {
  764.       if (childNodes[i].getTagName() == "CFPROPERTY")
  765.       {
  766.         var node = new PropertyInfo();
  767.         var result = node.deserialize(childNodes[i]);
  768.         if (result)
  769.         {
  770.           this.properties.push(node);
  771.         }
  772.         else
  773.         {
  774.           alert("ERROR parsing property:\n" +  childNodes[i].toString());
  775.           retVal = false;
  776.         }
  777.       }
  778.       else if (childNodes[i].getTagName() == "CFFUNCTION")
  779.       {
  780.         var node = new MethodInfo();
  781.         var result = node.deserialize(childNodes[i]);
  782.         if (result)
  783.         {
  784.           this.methods.push(node);
  785.         }
  786.         else
  787.         {
  788.           alert("ERROR parsing method:\n" +  childNodes[i].toString());
  789.           retVal = false;
  790.         }
  791.       }
  792.     }
  793.     
  794.     this.name = (this.name != null) ? this.name : "";
  795.     this.displayName = (this.displayName != null) ? this.displayName : "";
  796.     this.description = (this.description != null) ? this.description : "";
  797.     this.parent = (this.parent != null) ? this.parent : "";
  798.   }
  799.   else
  800.   {
  801.     alert("Error: Component tag not found");
  802.   }
  803.  
  804.   return retVal;
  805. }
  806.  
  807.  
  808. function ComponentInfo_validate()
  809. {
  810.   var retVal = new Array();  // use arrays for string concatenation, not +=
  811.   if( "" == this.name  || containsInvalidChars(this.name) ) {
  812.     retVal.push(++errorCount + ". " + dwscripts.sprintf(MSG_Error_BlankName, LABEL_Component));
  813.   }
  814.   if( "" == FILE_DIR ) {
  815.     retVal.push(++errorCount + MSG_Error_CompFileOutputDir);
  816.   }
  817.     
  818.   for (var i=0; i < this.properties.length; i++)
  819.   {
  820.     retVal.push(this.properties[i].validate());
  821.   }
  822.   
  823.   for (var i=0; i < this.methods.length; i++)
  824.   {
  825.     retVal.push(this.methods[i].validate());
  826.   }
  827.  
  828.   return retVal.join("");
  829. }
  830.  
  831.  
  832. //--------------------------------------------------------------------
  833. // CLASS:
  834. //   PropertyInfo
  835. //
  836. // DESCRIPTION:
  837. //   This class represents the information about a property
  838. //
  839. // PUBLIC PROPERTIES:
  840. //
  841. //   name
  842. //   displayName
  843. //   access
  844. //   type
  845. //   isArray
  846. //   description
  847. //   defaultValue
  848. //   required
  849. //   searchable
  850. //   fullText
  851. //
  852. // PUBLIC FUNCTIONS:
  853. //
  854. //   serialize()
  855. //   validate()
  856. //
  857. //--------------------------------------------------------------------
  858.  
  859. function PropertyInfo()
  860. {
  861.   this.name = "";
  862.   this.displayName = "";
  863.   this.access = "public";
  864.   this.type = "string";
  865.   this.isArray = false;
  866.   this.description = "";
  867.   this.defaultValue = "";
  868.   this.required = false;
  869.   this.searchable = false;
  870.   this.fullText = false;
  871. }
  872.  
  873. PropertyInfo.prototype.serialize = PropertyInfo_serialize;
  874. PropertyInfo.prototype.serializeToTagEdit = PropertyInfo_serializeToTagEdit;
  875. PropertyInfo.prototype.deserialize = PropertyInfo_deserialize;
  876. PropertyInfo.prototype.validate = PropertyInfo_validate;
  877.  
  878.  
  879. function PropertyInfo_serialize()
  880. {
  881.   var propertyTag = this.serializeToTagEdit();
  882.   
  883.   propertyTag.format("\t");
  884.   
  885.   return propertyTag.getOuterHTML();
  886. }
  887.  
  888.  
  889. function PropertyInfo_serializeToTagEdit(tagToSet)
  890. {
  891.   var propertyTag = null
  892.   if (tagToSet)
  893.   {
  894.     propertyTag = tagToSet;
  895.   }
  896.   else
  897.   {
  898.     propertyTag = new TagEdit("<cfproperty>");
  899.   }
  900.   
  901.   propertyTag.setAttribute("name", this.name);
  902.   if (this.displayName)
  903.   {
  904.     propertyTag.setAttribute("displayName", this.displayName);
  905.   }
  906.   if  (this.description)
  907.   {
  908.     propertyTag.setAttribute("hint", this.description);
  909.   }
  910.   //propertyTag.setAttribute("access", this.access);
  911.  
  912.   if (this.type)
  913.   {
  914.     var trimmedType = this.type;
  915.     trimmedType = dwscripts.trim(trimmedType);
  916.     if (trimmedType.length > 0)
  917.     {
  918.       propertyTag.setAttribute("type" , trimmedType);
  919.     }
  920.   }
  921.  
  922.   if (this.defaultValue)
  923.   {
  924.     propertyTag.setAttribute("default" , this.defaultValue);
  925.   }
  926.   if (this.required)
  927.   {
  928.     propertyTag.setAttribute("required" , this.required);
  929.   }
  930.   if (this.searchable)
  931.   {
  932.     propertyTag.setAttribute("searchable" , this.searchable);
  933.   }
  934.   if (this.fullText)
  935.   {
  936.     propertyTag.setAttribute("fullText" , this.fullText);
  937.   }
  938.   
  939.   return propertyTag;
  940. }
  941.  
  942.  
  943. function PropertyInfo_deserialize(tagSource)
  944. {
  945.   var retVal = false;
  946.   
  947.   var propertyTag = null;
  948.   
  949.   if (typeof tagSource == "string")
  950.   {
  951.     // use the tag edit class to read out the properties
  952.     var tagList = TagEdit.parseString(tagSource);
  953.  
  954.     // set the propertyTag
  955.     if (tagList)
  956.     {
  957.       for (var i=0; i < tagList.length; i++)
  958.       {
  959.         if (tagList[i].getTagName() == "CFPROPERTY")
  960.         {
  961.           propertyTag = tagList[i];
  962.           break;
  963.         }
  964.       }
  965.     }
  966.   }
  967.   else
  968.   {
  969.     propertyTag = tagSource;
  970.   }
  971.   
  972.   if (propertyTag)
  973.   {
  974.     retVal = true;
  975.  
  976.     this.name = propertyTag.getAttribute("name");
  977.     this.displayName = propertyTag.getAttribute("displayName");
  978.     this.description = propertyTag.getAttribute("hint");
  979.     this.access = propertyTag.getAttribute("access");
  980.     this.type = propertyTag.getAttribute("type");
  981.     this.defaultValue = propertyTag.getAttribute("default");
  982.     this.required = (propertyTag.getAttribute("required") == "true");
  983.     this.searchable = (propertyTag.getAttribute("searchable") == "true");
  984.     this.fullText = propertyTag.getAttribute("fullText");
  985.     
  986.     this.name = (this.name != null) ? this.name : "";
  987.     this.displayName = (this.displayName != null) ? this.displayName : "";
  988.     this.description = (this.description != null) ? this.description : "";
  989.     this.access = (this.access != null) ? this.access : "public";
  990.     this.type = (this.type != null) ? this.type : "string";
  991.     this.defaultValue = (this.defaultValue != null) ? this.defaultValue : "";
  992.     this.fullText = (this.fullText != null) ? this.fullText : "";
  993.   }
  994.   
  995.   return retVal;
  996. }
  997.  
  998.  
  999. function PropertyInfo_validate()
  1000. {
  1001.   var retVal = new Array();  // use arrays for string concatenation, not +=
  1002.   
  1003.   return retVal.join("");
  1004. }
  1005.  
  1006.  
  1007. //--------------------------------------------------------------------
  1008. // CLASS:
  1009. //   MethodInfo
  1010. //
  1011. // DESCRIPTION:
  1012. //   This class represents information about a method
  1013. //
  1014. // PUBLIC PROPERTIES:
  1015. //
  1016. //   name
  1017. //   displayName
  1018. //   description
  1019. //   access
  1020. //   isStatic
  1021. //   resultType
  1022. //   output
  1023. //     
  1024. //   parameters
  1025. //
  1026. // PUBLIC FUNCTIONS:
  1027. //   
  1028. //   serialize()
  1029. //   validate()
  1030. //
  1031. //--------------------------------------------------------------------
  1032.  
  1033. function MethodInfo()
  1034. {
  1035.   this.name = "";
  1036.   this.displayName = "";
  1037.   this.description = "";
  1038.   this.access = "public";
  1039.   this.roles = "";
  1040.   this.isStatic = false;
  1041.   this.resultType = "";
  1042.   this.output = false;
  1043.   
  1044.   this.parameters = new Array(); // array of parameter info
  1045. }
  1046.  
  1047. MethodInfo.prototype.serialize = MethodInfo_serialize;
  1048. MethodInfo.prototype.serializeToTagEdit = MethodInfo_serializeToTagEdit;
  1049. MethodInfo.prototype.deserialize = MethodInfo_deserialize;
  1050. MethodInfo.prototype.validate = MethodInfo_validate;
  1051.  
  1052.  
  1053. function MethodInfo_serialize()
  1054. {
  1055.   var methodTag = this.serializeToTagEdit();
  1056.   
  1057.   methodTag.format("\t");
  1058.   
  1059.   return methodTag.getOuterHTML();
  1060. }
  1061.  
  1062.  
  1063. function MethodInfo_serializeToTagEdit(tagToSet)
  1064. {
  1065.   var methodTag = null;
  1066.   if (tagToSet)
  1067.   {
  1068.     methodTag = tagToSet;
  1069.   }
  1070.   else
  1071.   {
  1072.     methodTag = new TagEdit("<cffunction></cffunction>");
  1073.   }
  1074.   
  1075.   methodTag.setAttribute("name", this.name);
  1076.   var retVal = new Array();  
  1077.   if (this.displayName)
  1078.   {
  1079.     methodTag.setAttribute("displayName", this.displayName);
  1080.   }
  1081.   if (this.description)
  1082.   {
  1083.     methodTag.setAttribute("hint", this.description);
  1084.   }
  1085.   methodTag.setAttribute("access", this.access);
  1086.   //methodTag.setAttribute("static", this.isStatic);
  1087.   if (this.roles)
  1088.   {
  1089.     methodTag.setAttribute("roles", this.roles);
  1090.   }
  1091.  
  1092.   if (this.resultType)
  1093.   {
  1094.     var trimmedType = this.resultType;
  1095.     trimmedType = dwscripts.trim(trimmedType);
  1096.     if (trimmedType.length > 0)
  1097.     {
  1098.       methodTag.setAttribute("returnType", trimmedType);
  1099.     }
  1100.   }
  1101.  
  1102.   methodTag.setAttribute("output", this.output.toString());
  1103.   
  1104.   var paramNodes = new Array();
  1105.   for (var i=0; i < this.parameters.length; i++)
  1106.   {
  1107.     paramNodes.push(this.parameters[i].serializeToTagEdit());
  1108.   }
  1109.   var childNodes = paramNodes;  
  1110.   var cffunctionComment = new TagEdit("\r\n\r\n<!--- " + this.name + " body --->");
  1111.   childNodes.push(cffunctionComment);
  1112.  
  1113.   if (this.resultType && "none" != this.resultType)
  1114.   {
  1115.     var cfreturnNode = new TagEdit("\r\n\r\n<cfreturn >");
  1116.     childNodes.push(cfreturnNode);
  1117.   }
  1118.  
  1119.   methodTag.setChildNodes(childNodes);
  1120.   
  1121.   return methodTag;
  1122. }
  1123.  
  1124.  
  1125. function MethodInfo_deserialize(tagSource)
  1126. {
  1127.   var retVal = false;
  1128.   
  1129.   var methodTag = null;
  1130.   
  1131.   if (typeof tagSource == "string")
  1132.   {
  1133.     // use the tag edit class to read out the properties
  1134.     var tagList = TagEdit.parseString(tagSource);
  1135.  
  1136.     // set the propertyTag
  1137.     if (tagList)
  1138.     {
  1139.       for (var i=0; i < tagList.length; i++)
  1140.       {
  1141.         if (tagList[i].getTagName() == "CFFUNCTION")
  1142.         {
  1143.           methodTag = tagList[i];
  1144.           break;
  1145.         }
  1146.       }
  1147.     }
  1148.   }
  1149.   else
  1150.   {
  1151.     methodTag = tagSource;
  1152.   }
  1153.   
  1154.   if (methodTag)
  1155.   {
  1156.     retVal = true;
  1157.     
  1158.     this.name = methodTag.getAttribute("name");
  1159.     this.displayName = methodTag.getAttribute("displayName");
  1160.     this.description = methodTag.getAttribute("hint");
  1161.     this.access = methodTag.getAttribute("access");
  1162.     this.roles = methodTag.getAttribute("roles");
  1163.     //this.isStatic = (methodTag.getAttribute("static") == "true");
  1164.     this.resultType = methodTag.getAttribute("returnType");
  1165.     this.output = (methodTag.getAttribute("output") == "true");
  1166.     
  1167.     var childNodes = methodTag.getChildNodes();
  1168.  
  1169.     this.parameters = new Array();
  1170.     
  1171.     // get the parameters
  1172.     for (var i=0; i < childNodes.length; i++)
  1173.     {
  1174.       if (childNodes[i].getTagName() == "CFARGUMENT")
  1175.       {
  1176.         var node = new ParameterInfo();
  1177.         var result = node.deserialize(childNodes[i]);
  1178.         if (result)
  1179.         {
  1180.           this.parameters.push(node);
  1181.         }
  1182.         else
  1183.         {
  1184.           retVal = false;
  1185.         }
  1186.       }
  1187.     }
  1188.  
  1189.     this.name = (this.name != null) ? this.name : "";
  1190.     this.displayName = (this.displayName != null) ? this.displayName : "";
  1191.     this.description = (this.description != null) ? this.description : "";
  1192.     this.access = (this.access != null) ? this.access : "";
  1193.     this.roles = (this.roles != null) ? this.roles : "";
  1194.     this.resultType = (this.resultType != null) ? this.resultType : "";
  1195.   }
  1196.   
  1197.   return retVal;
  1198. }
  1199.  
  1200.  
  1201. function MethodInfo_validate()
  1202. {
  1203.   var retVal = new Array();  // use arrays for string concatenation, not +=
  1204.   
  1205.   for (var i=0; i < this.parameters.length; i++)
  1206.   {
  1207.     retVal.push(this.parameters[i].validate());
  1208.   }
  1209.   
  1210.   return retVal.join("");
  1211. }
  1212.  
  1213.  
  1214. //--------------------------------------------------------------------
  1215. // CLASS:
  1216. //   ParameterInfo
  1217. //
  1218. // DESCRIPTION:
  1219. //   This class represent information about a parameter
  1220. //
  1221. // PUBLIC PROPERTIES:
  1222. //
  1223. //   name
  1224. //   displayName
  1225. //   description
  1226. //   type
  1227. //   required
  1228. //   defaultValue
  1229. //
  1230. // PUBLIC FUNCTIONS:
  1231. //
  1232. //   serialize()
  1233. //   validate()
  1234. //
  1235. //--------------------------------------------------------------------
  1236.  
  1237. function ParameterInfo()
  1238. {
  1239.   this.name = "";
  1240.   this.displayName = "";
  1241.   this.description = "";
  1242.   this.type = "string";
  1243.   this.required = false;
  1244.   this.defaultValue = "";
  1245. }
  1246.  
  1247. ParameterInfo.prototype.serialize = ParameterInfo_serialize;
  1248. ParameterInfo.prototype.serializeToTagEdit = ParameterInfo_serializeToTagEdit;
  1249. ParameterInfo.prototype.deserialize = ParameterInfo_deserialize;
  1250. ParameterInfo.prototype.validate = ParameterInfo_validate;
  1251.  
  1252.  
  1253. function ParameterInfo_serialize()
  1254. {
  1255.   var parameterTag = this.serializeToTagEdit();
  1256.   
  1257.   parameterTag.format("\t");
  1258.   
  1259.   return parameterTag.getOuterHTML();
  1260. }
  1261.  
  1262.  
  1263. function ParameterInfo_serializeToTagEdit(tagToSet)
  1264. {
  1265.   var parameterTag = null;
  1266.   if (tagToSet)
  1267.   {
  1268.     parameterTag = tagToSet;
  1269.   }
  1270.   else
  1271.   {
  1272.     parameterTag = new TagEdit("<cfargument>");
  1273.   }
  1274.   
  1275.   parameterTag.setAttribute("name", this.name);
  1276.   if (this.displayName)
  1277.   {
  1278.     parameterTag.setAttribute("displayName", this.displayName);
  1279.   }
  1280.   if (this.description)
  1281.   {
  1282.     parameterTag.setAttribute("hint", this.description);
  1283.   }
  1284.  
  1285.   if (this.type)
  1286.   {
  1287.     var trimmedType = this.type;
  1288.     trimmedType = dwscripts.trim(trimmedType);
  1289.     if (trimmedType.length > 0)
  1290.     {
  1291.       parameterTag.setAttribute("type", trimmedType + ((this.isArray) ? '[]' : ''));
  1292.     }
  1293.   }
  1294.  
  1295.   if (this.required)
  1296.   {
  1297.     parameterTag.setAttribute("required", this.required);
  1298.   }
  1299.   if (this.defaultValue)
  1300.   {
  1301.     parameterTag.setAttribute("default", this.defaultValue);
  1302.   }
  1303.   
  1304.   return parameterTag;
  1305. }
  1306.  
  1307. function ParameterInfo_deserialize(tagSource)
  1308. {
  1309.   var retVal = false;
  1310.   
  1311.   var parameterTag = null;
  1312.   
  1313.   if (typeof tagSource == "string")
  1314.   {
  1315.     // use the tag edit class to read out the properties
  1316.     var tagList = TagEdit.parseString(tagSource);
  1317.  
  1318.     // set the parameterTag
  1319.     if (tagList)
  1320.     {
  1321.       for (var i=0; i < tagList.length; i++)
  1322.       {
  1323.         if (tagList[i].getTagName() == "CFARGUMENT")
  1324.         {
  1325.           parameterTag = tagList[i];
  1326.           break;
  1327.         }
  1328.       }
  1329.     }
  1330.   }
  1331.   else
  1332.   {
  1333.     parameterTag = tagSource;
  1334.   }
  1335.   
  1336.   if (parameterTag)
  1337.   {
  1338.     retVal = true;
  1339.     
  1340.     this.name = parameterTag.getAttribute("name");
  1341.     this.displayName = parameterTag.getAttribute("displayName");
  1342.     this.description = parameterTag.getAttribute("hint");
  1343.     this.type = parameterTag.getAttribute("type");
  1344.     this.required = (parameterTag.getAttribute("required") == "true");
  1345.     this.defaultValue = parameterTag.getAttribute("default");
  1346.     
  1347.     this.name = (this.name != null) ? this.name : "";
  1348.     this.displayName = (this.displayName != null) ? this.displayName : "";
  1349.     this.description = (this.description != null) ? this.description : "";
  1350.     this.type = (this.type != null) ? this.type : "string";
  1351.     this.defaultValue = (this.defaultValue != null) ? this.defaultValue : "";
  1352.   }
  1353.   
  1354.   return retVal;
  1355. }
  1356.  
  1357.  
  1358. function ParameterInfo_validate()
  1359. {
  1360.   var retVal = new Array();  // use arrays for string concatenation, not +=
  1361.   
  1362.   return retVal.join("");
  1363. }
  1364.  
  1365.  
  1366.  
  1367. //--------------------------------------------------------------------
  1368. // Page Classes
  1369. // 
  1370. //  Please see the TabControlClass.js file in Shared/MM/Scripts/Class
  1371. //  for more information on the functions defined within these classes
  1372. //
  1373. //--------------------------------------------------------------------
  1374.  
  1375.  
  1376.  
  1377.  
  1378. //--------------------------------------------------------------------
  1379. // CLASS:
  1380. //   ComponentsPage
  1381. //
  1382. // DESCRIPTION:
  1383. //   This class handles the display and update of the component page
  1384. //
  1385. // PUBLIC PROPERTIES:
  1386. //   NONE
  1387. //
  1388. // PUBLIC FUNCTIONS:
  1389. //   NONE
  1390. //
  1391. //--------------------------------------------------------------------
  1392.  
  1393. function ComponentsPage(theTabLabel)
  1394. {
  1395.   this.tabLabel = theTabLabel;
  1396.   
  1397.   // controls
  1398.   this.compName = "";
  1399.   this.compDisplayName = "";
  1400.   this.compDescription = "";
  1401.   this.compParent = "";
  1402.   this.compFileOutputDir = "";
  1403. }
  1404.  
  1405. ComponentsPage.prototype.getTabLabel = ComponentsPage_getTabLabel;
  1406. ComponentsPage.prototype.canLoad = ComponentsPage_canLoad;
  1407. ComponentsPage.prototype.load = ComponentsPage_load;
  1408. ComponentsPage.prototype.update = ComponentsPage_update;
  1409. ComponentsPage.prototype.unload = ComponentsPage_unload;
  1410. ComponentsPage.prototype.lastUnload = ComponentsPage_lastUnload;
  1411.  
  1412. function ComponentsPage_getTabLabel()
  1413. {
  1414.   return this.tabLabel;
  1415. }
  1416.  
  1417. //Called to check if a page can be loaded
  1418. //
  1419. function ComponentsPage_canLoad()
  1420. {
  1421.   //alert("canLoad() called " + this.tabLabel);
  1422.   return true;
  1423. }
  1424.  
  1425. //Called when the layer for this page is displayed.
  1426. // Use this call to initialize controls.
  1427. //
  1428. function ComponentsPage_load()
  1429. {
  1430.   //alert("load() called " + this.tabLabel + " (loaded = " + this.loaded + ")");
  1431.   this.compName = dwscripts.findDOMObject("compName");
  1432.   this.compDisplayName = dwscripts.findDOMObject("compDisplayName");
  1433.   this.compDescription = dwscripts.findDOMObject("compDescription");
  1434.   this.compParent = new ListControl("compParent");
  1435.   this.compFileOutputDir = new ListControl("compFileOutputDir");
  1436.  
  1437.   this.compParent.setAll(LABEL_PARENT_CFCS,LABEL_PARENT_CFCS);
  1438.   this.compFileOutputDir.setAll(LABEL_CFC_ROOTS,LABEL_CFC_ROOTS);
  1439.  
  1440.   this.update("refresh");
  1441. }
  1442.  
  1443. //Called when one of the page controls calls the tabControl update function.
  1444. // Use this call to respond to user input.
  1445. //
  1446. function ComponentsPage_update(theItemName)
  1447. {
  1448.   //alert("update() called for " + theItemName + " on " + this.tabLabel);
  1449.   
  1450.   if (theItemName == "refresh")
  1451.   {
  1452.     this.compName.value = COMPONENT_INFO.name;
  1453.     this.compDisplayName.value = COMPONENT_INFO.displayName;
  1454.     this.compDescription.value = COMPONENT_INFO.description;
  1455.     this.compParent.pick(COMPONENT_INFO.parent);
  1456.     this.compFileOutputDir.set(FILE_DIR,-1);
  1457.   }
  1458.  
  1459.   if (theItemName == "compName")
  1460.   {
  1461.     COMPONENT_INFO.name = this.compName.value;
  1462.   }
  1463.   else if (theItemName == "compDisplayName")
  1464.   {
  1465.     COMPONENT_INFO.displayName = this.compDisplayName.value;
  1466.   }
  1467.   else if (theItemName == "compDescription")
  1468.   {
  1469.     COMPONENT_INFO.description = this.compDescription.value;
  1470.   } 
  1471.   else if (theItemName == "compParent")
  1472.   {
  1473.     COMPONENT_INFO.parent = this.compParent.getValue();
  1474.   } 
  1475.   else if (theItemName == "FolderBrowse")
  1476.   {
  1477.     retVal = dwscripts.localURLToFilePath(dreamweaver.browseForFolderURL(LABEL_DirBrowse));
  1478.     if (retVal)
  1479.     {
  1480.       // need the optional index of -1 so it doesn't override the selectedIndex
  1481.       this.compFileOutputDir.set(retVal,-1);
  1482.     }
  1483.   }
  1484.   else if (theItemName == "saveToTemplate")
  1485.   {
  1486.     saveToTemplate();
  1487.   }
  1488.   else if (theItemName == "loadFromTemplate")
  1489.   {
  1490.     loadFromTemplate();
  1491.     this.update("refresh");
  1492.   }
  1493. }
  1494.  
  1495. //Called when another page is about to be shown, or finish() is called on
  1496. // the tabControl.  Use this call to perform any finishing tasks.
  1497. //
  1498. function ComponentsPage_unload()
  1499. {
  1500.   //alert("unload() called " + this.tabLabel);
  1501.   
  1502.   COMPONENT_INFO.name = this.compName.value;
  1503.   COMPONENT_INFO.displayName = this.compDisplayName.value;
  1504.   COMPONENT_INFO.description = this.compDescription.value;
  1505.   COMPONENT_INFO.parent = this.compParent.get();
  1506.   FILE_DIR = this.compFileOutputDir.get();
  1507.   
  1508.   // do any checking needed while changing pages.
  1509.   // return false if we should remain on this page.
  1510.  
  1511.   // hack to make sure that controls disappear correctly
  1512.   T.obj.visibility = "hidden";
  1513.   T.obj.visibility = "visible";
  1514.     
  1515.   return true;
  1516. }
  1517.  
  1518. //Called when finish() is called on the tabControl.
  1519. // Use this call to perform any last minute page updates.
  1520. //
  1521. function ComponentsPage_lastUnload()
  1522. {
  1523.   //alert("lastUnload() called " + this.tabLabel);
  1524.   return true;
  1525. }
  1526.  
  1527.  
  1528.  
  1529.  
  1530. //--------------------------------------------------------------------
  1531. // CLASS:
  1532. //   PropertiesPage
  1533. //
  1534. // DESCRIPTION:
  1535. //   This class handles the display and update of the properties page
  1536. //
  1537. // PUBLIC PROPERTIES:
  1538. //   NONE
  1539. //
  1540. // PUBLIC FUNCTIONS:
  1541. //   NONE
  1542. //
  1543. //--------------------------------------------------------------------
  1544.  
  1545. function PropertiesPage(theTabLabel)
  1546. {
  1547.   this.tabLabel = theTabLabel;
  1548.   
  1549.   this.properties = "";
  1550.   this.propName = "";
  1551.   this.propDisplayName = "";
  1552.   this.propDescription = "";
  1553.   //this.propAccess = "";
  1554.   this.propType = "";
  1555.   this.propArray = ""; 
  1556.   //this.propDefaultValue = "";
  1557.   //this.propRequired = "";
  1558.   this.propSearchable = "";
  1559.   this.propFullText = "";
  1560.  
  1561.   this.selectedProperty = -1;
  1562.   
  1563.   this.pageIsEnabled = true;
  1564. }
  1565.  
  1566. PropertiesPage.prototype.getTabLabel = PropertiesPage_getTabLabel;
  1567. PropertiesPage.prototype.canLoad = PropertiesPage_canLoad;
  1568. PropertiesPage.prototype.load = PropertiesPage_load;
  1569. PropertiesPage.prototype.update = PropertiesPage_update;
  1570. PropertiesPage.prototype.unload = PropertiesPage_unload;
  1571. PropertiesPage.prototype.lastUnload = PropertiesPage_lastUnload;
  1572.  
  1573. PropertiesPage.prototype.enable = PropertiesPage_enable;
  1574. PropertiesPage.prototype.disable = PropertiesPage_disable;
  1575.  
  1576. function PropertiesPage_getTabLabel()
  1577. {
  1578.   return this.tabLabel;
  1579. }
  1580.  
  1581. //Called to check if a page can be loaded
  1582. //
  1583. function PropertiesPage_canLoad()
  1584. {
  1585.   //alert("canLoad() called " + this.tabLabel);
  1586.   return true;
  1587. }
  1588.  
  1589. //Called when the layer for this page is displayed.
  1590. // Use this call to initialize controls.
  1591. //
  1592. function PropertiesPage_load()
  1593. {
  1594.   //alert("load() called " + this.tabLabel + " (loaded = " + this.loaded + ")");
  1595.   
  1596.   this.properties = new ListControl("properties");
  1597.   this.propName = dwscripts.findDOMObject("propName");
  1598.   this.propDisplayName = dwscripts.findDOMObject("propDisplayName");
  1599.   this.propDescription = dwscripts.findDOMObject("propDescription");
  1600.   //this.propAccess = new ListControl("propAccess");
  1601.   this.propType = new ListControl("propType");
  1602.   //this.propArray = dwscripts.findDOMObject("propArray");
  1603.   //this.propDefaultValue = dwscripts.findDOMObject("propDefaultValue");
  1604.   //this.propRequired = dwscripts.findDOMObject("propRequired");
  1605.   //this.propSearchable = dwscripts.findDOMObject("propSearchable");
  1606.   //this.propFullText = dwscripts.findDOMObject("propFullText");
  1607.   
  1608.   // populate access list
  1609.   //this.propAccess.setAll(LABEL_ACCESSES,LABEL_ACCESSES);
  1610.   //this.propAccess.pickValue(DEFAULT_ACCESS);
  1611.   
  1612.   // populate the type list
  1613.   this.propType.setAll(LABEL_TYPES,LABEL_TYPES);
  1614.   
  1615.   this.update('refresh');
  1616. }
  1617.  
  1618. //Called when one of the page controls calls the tabControl update function.
  1619. // Use this call to respond to user input.
  1620. //
  1621. function PropertiesPage_update(theItemName)
  1622. {
  1623.   //alert("update() called for " + theItemName + " on " + this.tabLabel);
  1624.   
  1625.   if (theItemName == "refresh")
  1626.   {
  1627.     // populate the properties array
  1628.     var nameArray = new Array();
  1629.     for (var i=0; i < COMPONENT_INFO.properties.length; i++)
  1630.     {
  1631.       nameArray.push(COMPONENT_INFO.properties[i].name); // function call?
  1632.     }
  1633.     this.properties.setAll(nameArray);
  1634.  
  1635.     if (this.selectedProperty != -1)
  1636.     {
  1637.       this.properties.setIndex(this.selectedProperty);
  1638.     }
  1639.  
  1640.     // now update the rest of the display
  1641.     this.update('properties');
  1642.   }
  1643.   else if (theItemName == "btn_propPlus")
  1644.   {
  1645.     var property = new PropertyInfo();
  1646.     property.name = getUniqueName(LABEL_Property, COMPONENT_INFO.properties);
  1647.     COMPONENT_INFO.properties.push(property);  // should we insert this after selection?
  1648.     
  1649.     this.properties.append(property.name);
  1650.     this.properties.setIndex(COMPONENT_INFO.properties.length);
  1651.     
  1652.     this.update("properties");
  1653.   }
  1654.   else if (theItemName == "btn_propMinus")
  1655.   {
  1656.     var index = this.properties.getIndex();
  1657.     
  1658.     this.properties.del();
  1659.     
  1660.     // delete this property
  1661.     COMPONENT_INFO.properties.splice(index,1);
  1662.     
  1663.     this.update("properties");
  1664.   }
  1665.   else
  1666.   {
  1667.     var index = this.properties.getIndex();
  1668.     var property = null;
  1669.     if (index >= 0)
  1670.     {
  1671.       property = COMPONENT_INFO.properties[index];
  1672.     }
  1673.     
  1674.     if (property)
  1675.     {  
  1676.       this.enable();
  1677.       
  1678.       if (theItemName == "properties")
  1679.       {
  1680.         // update the other fields to display the currently
  1681.         //  selected item
  1682.         this.propName.value = property.name;
  1683.         this.propDisplayName.value = property.displayName;
  1684.         //this.propAccess.pickValue(property.access);
  1685.         this.propType.pickValue(property.type);
  1686.         //this.propArray.checked = property.isArray;
  1687.         this.propDescription.value = property.description;
  1688.         //this.propDefaultValue.value = property.defaultValue;
  1689.         //this.propRequired.checked = property.required;
  1690.         //this.propSearchable.checked = property.searchable;
  1691.         //this.propFullText.checked = property.fullText;
  1692.       }
  1693.       else if (theItemName == "propName")
  1694.       {
  1695.         if( "" == this.propName.value  || containsInvalidChars(this.propName.value) ) {
  1696.           alert(dwscripts.sprintf(MSG_Error_BlankName,LABEL_Property));
  1697.           dwscripts.findDOMObject("propName").focus();
  1698.         }
  1699.         else if ( nameExists(this.propName.value, this.properties) )
  1700.         {
  1701.           alert(dwscripts.sprintf(MSG_Error_NameExists, this.propName.value, LABEL_Property));
  1702.           dwscripts.findDOMObject("propName").focus();
  1703.         }
  1704.         else
  1705.         {
  1706.           property.name = this.propName.value;
  1707.           this.properties.set(property.name);
  1708.         }
  1709.       }
  1710.       else if (theItemName == "propDisplayName")
  1711.       {
  1712.         property.displayName = this.propDisplayName.value;
  1713.       }
  1714.       else if (theItemName == "propAccess")
  1715.       {
  1716.         //property.access = this.propAccess.getValue();
  1717.       }
  1718.       else if (theItemName == "propType")
  1719.       {
  1720.         var newValue = this.propType.getValue();
  1721.         if (property.type != newValue)
  1722.         {
  1723.           property.type = newValue;
  1724.           // need to repick the value to work around a bug
  1725.           this.propType.pickValue(property.type);
  1726.         }
  1727.       }
  1728.       else if (theItemName == "propDescription")
  1729.       {
  1730.         property.description = this.propDescription.value;
  1731.       }
  1732.       else if (theItemName == "propDefaultValue")
  1733.       {
  1734.         //property.defaultValue = this.propDefaultValue.value;
  1735.       }
  1736.       else if (theItemName == "propRequired")
  1737.       {
  1738.         //property.required = this.propRequired.checked;
  1739.       }
  1740.     }
  1741.     else
  1742.     {
  1743.       // clear items
  1744.       this.propName.value = "";
  1745.       this.propDisplayName.value = "";
  1746.       //this.propAccess.pickValue("public");
  1747.       this.propType.pickValue("string");
  1748.       //this.propArray.checked = false;
  1749.       this.propDescription.value = "";
  1750.       //this.propDefaultValue.value = "";
  1751.       //this.propRequired.checked = false;
  1752.       //this.propSearchable.checked = false;
  1753.       //this.propFullText.checked = false;
  1754.       
  1755.       // disable form
  1756.       this.disable();
  1757.     }
  1758.   }
  1759. }
  1760.  
  1761. //Called when another page is about to be shown, or finish() is called on
  1762. // the tabControl.  Use this call to perform any finishing tasks.
  1763. //
  1764. function PropertiesPage_unload()
  1765. {
  1766.   //alert("unload() called " + this.tabLabel);
  1767.   
  1768.   this.selectedProperty = this.properties.getIndex();
  1769.   
  1770.   // hack to make sure that controls disappear correctly
  1771.   T.obj.visibility = "hidden";
  1772.   T.obj.visibility = "visible";
  1773.   
  1774.   return true;
  1775. }
  1776.  
  1777. //Called when finish() is called on the tabControl.
  1778. // Use this call to perform any last minute page updates.
  1779. //
  1780. function PropertiesPage_lastUnload()
  1781. {
  1782.   //alert("lastUnload() called " + this.tabLabel);
  1783.   return true;
  1784. }
  1785.  
  1786.  
  1787. function PropertiesPage_enable()
  1788. {
  1789.   if (!this.pageIsEnabled)
  1790.   {
  1791.     this.pageIsEnabled = true;
  1792.     this.propName.removeAttribute("disabled");
  1793.     this.propDisplayName.removeAttribute("disabled");
  1794.     //this.propAccess.enable();
  1795.     this.propType.enable();
  1796.     //this.propArray.removeAttribute("disabled");
  1797.     this.propDescription.removeAttribute("disabled");
  1798.     //this.propDefaultValue.removeAttribute("disabled");
  1799.     //this.propRequired.removeAttribute("disabled");
  1800.     //this.propSearchable.removeAttribute("disabled");
  1801.     //this.propFullText.removeAttribute("disabled");
  1802.   }
  1803. }
  1804.  
  1805. function PropertiesPage_disable()
  1806. {
  1807.   if (this.pageIsEnabled)
  1808.   {
  1809.     this.pageIsEnabled = false;
  1810.     this.propName.setAttribute("disabled","true");
  1811.     this.propDisplayName.setAttribute("disabled","true");
  1812.     //this.propAccess.disable();
  1813.     this.propType.disable();
  1814.     //this.propArray.setAttribute("disabled","true");
  1815.     this.propDescription.setAttribute("disabled","true");
  1816.     //this.propDefaultValue.setAttribute("disabled","true");
  1817.     //this.propRequired.setAttribute("disabled","true");
  1818.     //this.propSearchable.setAttribute("disabled","true");
  1819.     //this.propFullText.setAttribute("disabled","true");
  1820.   }
  1821. }
  1822.  
  1823.  
  1824.  
  1825. //--------------------------------------------------------------------
  1826. // CLASS:
  1827. //   MethodsPage
  1828. //
  1829. // DESCRIPTION:
  1830. //   This class handles the display and update of the methods page
  1831. //
  1832. // PUBLIC PROPERTIES:
  1833. //   NONE
  1834. //
  1835. // PUBLIC FUNCTIONS:
  1836. //   NONE
  1837. //
  1838. //--------------------------------------------------------------------
  1839.  
  1840. function MethodsPage(theTabLabel)
  1841. {
  1842.   this.tabLabel = theTabLabel;
  1843.   
  1844.   this.methods = "";
  1845.   this.methodName = "";
  1846.   this.methodDisplayName = "";
  1847.   this.methodDescription = "";
  1848.   this.methodAccess = "";
  1849.   this.methodRoles = "";
  1850.   //this.methodStatic1 = "";
  1851.   this.methodResultType = "";
  1852.   this.methodOutput = "";
  1853.   
  1854.   this.selectedMethod = -1;
  1855.   
  1856.   this.pageIsEnabled = true;
  1857. }
  1858.  
  1859. MethodsPage.prototype.getTabLabel = MethodsPage_getTabLabel;
  1860. MethodsPage.prototype.canLoad = MethodsPage_canLoad;
  1861. MethodsPage.prototype.load = MethodsPage_load;
  1862. MethodsPage.prototype.update = MethodsPage_update;
  1863. MethodsPage.prototype.unload = MethodsPage_unload;
  1864. MethodsPage.prototype.lastUnload = MethodsPage_lastUnload;
  1865.  
  1866. MethodsPage.prototype.enable = MethodsPage_enable;
  1867. MethodsPage.prototype.disable = MethodsPage_disable;
  1868.  
  1869. function MethodsPage_getTabLabel()
  1870. {
  1871.   return this.tabLabel;
  1872. }
  1873.  
  1874. //Called to check if a page can be loaded
  1875. //
  1876. function MethodsPage_canLoad()
  1877. {
  1878.   //alert("canLoad() called " + this.tabLabel);
  1879.   return true;
  1880. }
  1881.  
  1882. //Called when the layer for this page is displayed.
  1883. // Use this call to initialize controls.
  1884. //
  1885. function MethodsPage_load()
  1886. {
  1887.   //alert("load() called " + this.tabLabel + " (loaded = " + this.loaded + ")");
  1888.   
  1889.   this.methods = new ListControl("methods");
  1890.   
  1891.   this.methodName = dwscripts.findDOMObject("methodName");
  1892.   this.methodDisplayName = dwscripts.findDOMObject("methodDisplayName");
  1893.   this.methodDescription = dwscripts.findDOMObject("methodDescription");
  1894.   this.methodAccess = new ListControl("methodAccess");
  1895.   this.methodRoles = dwscripts.findDOMObject("methodRoles");
  1896.   //this.methodStatic1 = dwscripts.findDOMObject("methodStatic1");
  1897.   this.methodResultType = new ListControl("methodResultType");
  1898.   this.methodOutput = dwscripts.findDOMObject("methodOutput");
  1899.   
  1900.   // populate the access list
  1901.   this.methodAccess.setAll(LABEL_ACCESSES,LABEL_ACCESSES);
  1902.   this.methodAccess.pickValue(DEFAULT_ACCESS);
  1903.   
  1904.   // populate the result type list
  1905.   var newList = new Array();
  1906.   var completeList = newList.concat(LABEL_TYPES);
  1907.   this.methodResultType.setAll(completeList,completeList);
  1908.  
  1909.   this.update("refresh");
  1910. }
  1911.  
  1912. //Called when one of the page controls calls the tabControl update function.
  1913. // Use this call to respond to user input.
  1914. //
  1915. function MethodsPage_update(theItemName)
  1916. {
  1917.   //alert("update() called for " + theItemName + " on " + this.tabLabel);
  1918.  
  1919.   if (theItemName == "refresh")
  1920.   {
  1921.     // populate the methods array
  1922.     var nameArray = new Array();
  1923.     for (var i=0; i < COMPONENT_INFO.methods.length; i++)
  1924.     {
  1925.       nameArray.push(COMPONENT_INFO.methods[i].name); // function call?
  1926.     }
  1927.     this.methods.setAll(nameArray);
  1928.  
  1929.     if (this.selectedMethod != -1)
  1930.     {
  1931.       this.methods.setIndex(this.selectedMethod);
  1932.     }
  1933.  
  1934.     // now update the rest of the display
  1935.     this.update('methods');
  1936.   }
  1937.   else if (theItemName == "btn_methodPlus")
  1938.   {
  1939.     var method = new MethodInfo();
  1940.     method.name = getUniqueName(LABEL_Method, COMPONENT_INFO.methods);
  1941.     COMPONENT_INFO.methods.push(method);  // should we insert this after selection?
  1942.     
  1943.     this.methods.append(method.name);
  1944.     this.methods.setIndex(COMPONENT_INFO.methods.length);
  1945.     
  1946.     this.update("methods");
  1947.   }
  1948.   else if (theItemName == "btn_methodMinus")
  1949.   {
  1950.     var index = this.methods.getIndex();
  1951.     
  1952.     this.methods.del();
  1953.     
  1954.     // delete this property
  1955.     COMPONENT_INFO.methods.splice(index,1);
  1956.     
  1957.     this.update("methods");
  1958.   }
  1959.   else
  1960.   {
  1961.     var index = this.methods.getIndex();
  1962.     var method = null;
  1963.     if (index >= 0)
  1964.     {
  1965.       method = COMPONENT_INFO.methods[index];
  1966.     }
  1967.     
  1968.     if (method)
  1969.     {
  1970.       this.enable();
  1971.       
  1972.       if (theItemName == "methods")
  1973.       {
  1974.         // update the other fields to display the currently
  1975.         //  selected item
  1976.         this.methodName.value = method.name;
  1977.         this.methodDisplayName.value = method.displayName;
  1978.         this.methodDescription.value = method.description;
  1979.         this.methodAccess.pickValue(method.access);
  1980.         this.methodRoles.value = method.roles;
  1981.         //this.methodStatic1.checked = method.isStatic;
  1982.         this.methodResultType.pickValue(method.resultType);
  1983.         this.methodOutput.checked = method.output;
  1984.       }
  1985.       else if (theItemName == "methodName")
  1986.       {
  1987.         if( "" == this.methodName.value  || containsInvalidChars(this.methodName.value) ) {
  1988.           alert(dwscripts.sprintf(MSG_Error_BlankName,LABEL_Method));
  1989.           dwscripts.findDOMObject("methodName").focus();
  1990.         }
  1991.         else if ( nameExists(this.methodName.value, this.methods) )
  1992.         {
  1993.           alert(dwscripts.sprintf(MSG_Error_NameExists, this.methodName.value, LABEL_Method));
  1994.           dwscripts.findDOMObject("methodName").focus();
  1995.         }
  1996.         else
  1997.         {
  1998.           method.name = this.methodName.value;
  1999.           this.methods.set(method.name);
  2000.         }
  2001.       }
  2002.       else if (theItemName == "methodDisplayName")
  2003.       {
  2004.         method.displayName = this.methodDisplayName.value;
  2005.       }
  2006.       else if (theItemName == "methodDescription")
  2007.       {
  2008.         method.description = this.methodDescription.value;
  2009.       }
  2010.       else if (theItemName == "methodAccess")
  2011.       {
  2012.         method.access = this.methodAccess.getValue();
  2013.       }
  2014.       else if (theItemName == "methodRoles")
  2015.       {
  2016.         method.roles = this.methodRoles.value;
  2017.       }
  2018.       //else if (theItemName == "methodStatic1")
  2019.       //{
  2020.         //method.isStatic = this.methodStatic1.checked;
  2021.       //}
  2022.       else if (theItemName == "methodResultType")
  2023.       {
  2024.         var newValue = this.methodResultType.getValue();
  2025.         if (method.resultType != newValue)
  2026.         {
  2027.           method.resultType = newValue;
  2028.           // need to repick the value to work around a bug
  2029.           this.methodResultType.pickValue(method.resultType);
  2030.         }
  2031.       }
  2032.       else if (theItemName == "methodOutput")
  2033.       {
  2034.         method.output = this.methodOutput.checked;
  2035.       }
  2036.     }
  2037.     else
  2038.     {
  2039.       // clear items
  2040.       this.methodName.value = "";
  2041.       this.methodDisplayName.value = "";
  2042.       this.methodDescription.value = "";
  2043.       this.methodAccess.pickValue("public");
  2044.       this.methodRoles.value = "";
  2045.       //this.methodStatic1.checked = false;
  2046.       this.methodResultType.pickValue("");
  2047.       this.methodOutput.checked = false;
  2048.       
  2049.       // disable form
  2050.       this.disable();
  2051.     }
  2052.   }
  2053. }
  2054.  
  2055. //Called when another page is about to be shown, or finish() is called on
  2056. // the tabControl.  Use this call to perform any finishing tasks.
  2057. //
  2058. function MethodsPage_unload()
  2059. {
  2060.   //alert("unload() called " + this.tabLabel);
  2061.  
  2062.   this.selectedMethod = this.methods.getIndex();
  2063.   
  2064.   // hack to make sure that controls disappear correctly
  2065.   T.obj.visibility = "hidden";
  2066.   T.obj.visibility = "visible";
  2067.   
  2068.   return true;
  2069. }
  2070.  
  2071. //Called when finish() is called on the tabControl.
  2072. // Use this call to perform any last minute page updates.
  2073. //
  2074. function MethodsPage_lastUnload()
  2075. {
  2076.   //alert("lastUnload() called " + this.tabLabel);
  2077.   return true;
  2078. }
  2079.  
  2080.  
  2081. function MethodsPage_enable()
  2082. {
  2083.   if (!this.pageIsEnabled)
  2084.   {
  2085.     this.pageIsEnabled = true;
  2086.     this.methodName.removeAttribute("disabled");
  2087.     this.methodDisplayName.removeAttribute("disabled");
  2088.     this.methodDescription.removeAttribute("disabled");
  2089.     this.methodAccess.enable();
  2090.     this.methodRoles.removeAttribute("disabled");
  2091.     //this.methodStatic1.removeAttribute("disabled");
  2092.     this.methodResultType.enable();
  2093.     this.methodOutput.removeAttribute("disabled");
  2094.   }
  2095. }
  2096.  
  2097. function MethodsPage_disable()
  2098. {
  2099.   if (this.pageIsEnabled)
  2100.   {
  2101.     this.pageIsEnabled = false;
  2102.     this.methodName.setAttribute("disabled","true");
  2103.     this.methodDisplayName.setAttribute("disabled","true");
  2104.     this.methodDescription.setAttribute("disabled","true");
  2105.     this.methodAccess.disable();
  2106.     this.methodRoles.setAttribute("disabled","true");
  2107.     //this.methodStatic1.setAttribute("disabled","true");
  2108.     this.methodResultType.disable();
  2109.     this.methodOutput.setAttribute("disabled","true");
  2110.   }
  2111. }
  2112.  
  2113.  
  2114.  
  2115. //--------------------------------------------------------------------
  2116. // CLASS:
  2117. //   ParametersPage
  2118. //
  2119. // DESCRIPTION:
  2120. //   This class handles the display and update of the parameters page
  2121. //
  2122. // PUBLIC PROPERTIES:
  2123. //   NONE
  2124. //
  2125. // PUBLIC FUNCTIONS:
  2126. //   NONE
  2127. //
  2128. //--------------------------------------------------------------------
  2129.  
  2130. function ParametersPage(theTabLabel)
  2131. {
  2132.   this.tabLabel = theTabLabel;
  2133.   
  2134.   this.readOnlyMethods = "";
  2135.   
  2136.   this.parameters = "";
  2137.   this.parameterName = "";
  2138.   this.parameterDisplayName = "";
  2139.   this.parameterDescription = "";
  2140.   this.parameterType = "";
  2141.   //this.parameterArray = "";
  2142.   this.parameterRequired = "";
  2143.   this.parameterDefaultValue = "";
  2144.   
  2145.   
  2146.   this.selectedMethod = -1;
  2147.   this.selectedParameter = -1;
  2148.   
  2149.   this.paramsEnabled = true;
  2150.   this.pageIsEnabled = true;
  2151. }
  2152.  
  2153. ParametersPage.prototype.getTabLabel = ParametersPage_getTabLabel;
  2154. ParametersPage.prototype.canLoad = ParametersPage_canLoad;
  2155. ParametersPage.prototype.load = ParametersPage_load;
  2156. ParametersPage.prototype.update = ParametersPage_update;
  2157. ParametersPage.prototype.unload = ParametersPage_unload;
  2158. ParametersPage.prototype.lastUnload = ParametersPage_lastUnload;
  2159.  
  2160. ParametersPage.prototype.enable = ParametersPage_enable;
  2161. ParametersPage.prototype.disable = ParametersPage_disable;
  2162.  
  2163. function ParametersPage_getTabLabel()
  2164. {
  2165.   return this.tabLabel;
  2166. }
  2167.  
  2168. //Called to check if a page can be loaded
  2169. //
  2170. function ParametersPage_canLoad()
  2171. {
  2172.   //alert("canLoad() called " + this.tabLabel);
  2173.   return true;
  2174. }
  2175.  
  2176. //Called when the layer for this page is displayed.
  2177. // Use this call to initialize controls.
  2178. //
  2179. function ParametersPage_load()
  2180. {
  2181.   //alert("load() called " + this.tabLabel + " (loaded = " + this.loaded + ")");
  2182.   
  2183.   this.readOnlyMethods = new ListControl("readOnlyMethods");
  2184.   this.parameters = new ListControl("parameters");
  2185.   this.parameterName = dwscripts.findDOMObject("parameterName");
  2186.   this.parameterDisplayName = dwscripts.findDOMObject("parameterDisplayName");
  2187.   this.parameterDescription = dwscripts.findDOMObject("parameterDescription");
  2188.   this.parameterType = new ListControl("parameterType");
  2189.   //this.parameterArray = dwscripts.findDOMObject("parameterArray");
  2190.   this.parameterRequired = dwscripts.findDOMObject("parameterRequired");
  2191.   this.parameterDefaultValue = dwscripts.findDOMObject("parameterDefaultValue");
  2192.   
  2193.   // populate the parameter type array
  2194.   this.parameterType.setAll(LABEL_TYPES,LABEL_TYPES);
  2195.   
  2196.   this.update("refresh");
  2197. }
  2198.  
  2199. //Called when one of the page controls calls the tabControl update function.
  2200. // Use this call to respond to user input.
  2201. //
  2202. function ParametersPage_update(theItemName)
  2203. {
  2204.   //alert("update() called for " + theItemName + " on " + this.tabLabel);
  2205.   
  2206.   if (theItemName == "refresh")
  2207.   {
  2208.     // populate the methods array
  2209.     var nameArray = new Array();
  2210.     for (var i=0; i < COMPONENT_INFO.methods.length; i++)
  2211.     {
  2212.       nameArray.push(COMPONENT_INFO.methods[i].name); // function call?
  2213.     }
  2214.     this.readOnlyMethods.setAll(nameArray,nameArray);
  2215.  
  2216.     if (this.selectedMethod != -1)
  2217.     {
  2218.       this.readOnlyMethods.setIndex(this.selectedMethod);
  2219.     }
  2220.  
  2221.     // now update the rest of the display
  2222.     this.update('readOnlyMethods');    
  2223.   }
  2224.   else
  2225.   {
  2226.     var index = this.readOnlyMethods.getIndex();
  2227.     var method = null;
  2228.     if (index >= 0)
  2229.     {
  2230.       method = COMPONENT_INFO.methods[index];
  2231.     }
  2232.  
  2233.     if (method)
  2234.     {
  2235.       if (!this.paramsEnabled)
  2236.       {
  2237.         this.parameters.enable();
  2238.         this.paramsEnabled = true;
  2239.         var plusButton = dwscripts.findDOMObject("btn_parameterPlus");
  2240.         plusButton.src = "../Shared/UltraDev/Images/PlusButton.gif";
  2241.         var minusButton = dwscripts.findDOMObject("btn_parameterMinus");
  2242.         minusButton.src = "../Shared/UltraDev/Images/MinusButtonEnabled.gif";
  2243.       }
  2244.  
  2245.       if (theItemName == "readOnlyMethods")
  2246.       {
  2247.         // populate the parameters array
  2248.         var nameArray = new Array();
  2249.         for (var i=0; i < method.parameters.length; i++)
  2250.         {
  2251.           nameArray.push(method.parameters[i].name); // function call?
  2252.         }
  2253.         this.parameters.setAll(nameArray,nameArray);
  2254.  
  2255.         if (this.selectedParameter != -1)
  2256.         {
  2257.           this.parameters.setIndex(this.selectedParameter);
  2258.           this.selectedParameter = -1;  // only select this the first time the page is visited
  2259.         }
  2260.         this.update("parameters");
  2261.       }
  2262.       if (theItemName == "btn_parameterPlus")
  2263.       {
  2264.         var parameter = new ParameterInfo();
  2265.         parameter.name = getUniqueName(LABEL_Parameter, method.parameters);
  2266.         method.parameters.push(parameter);  // should we insert this after selection?
  2267.  
  2268.         this.parameters.append(parameter.name);
  2269.         this.parameters.setIndex(method.parameters.length);
  2270.  
  2271.         this.update("parameters");
  2272.       }
  2273.       else if (theItemName == "btn_parameterMinus")
  2274.       {
  2275.         var paramIndex = this.parameters.getIndex();
  2276.  
  2277.         this.parameters.del();
  2278.  
  2279.         // delete this property
  2280.         method.parameters.splice(paramIndex,1);
  2281.  
  2282.         this.update("parameters");
  2283.       }
  2284.       else
  2285.       {
  2286.         var paramIndex = this.parameters.getIndex();
  2287.         var parameter = null;
  2288.         if (paramIndex >= 0)
  2289.         {
  2290.           parameter = method.parameters[paramIndex];
  2291.         }
  2292.  
  2293.         if (parameter)
  2294.         {
  2295.           this.enable();
  2296.  
  2297.           if (theItemName == "parameters")
  2298.           {
  2299.             // update the other fields to display the currently
  2300.             //  selected item
  2301.             this.parameterName.value = parameter.name;
  2302.             this.parameterDisplayName.value = parameter.displayName;
  2303.             this.parameterDescription.value = parameter.description;
  2304.             this.parameterType.pickValue(parameter.type);
  2305.             this.parameterRequired.checked = parameter.required;
  2306.             this.parameterDefaultValue.value = parameter.defaultValue;
  2307.           }
  2308.           else if (theItemName == "parameterName")
  2309.           {
  2310.             if( "" == this.parameterName.value  || containsInvalidChars(this.parameterName.value) ) {
  2311.               alert(dwscripts.sprintf(MSG_Error_BlankName,LABEL_Parameter));
  2312.               dwscripts.findDOMObject("parameterName").focus();
  2313.             }
  2314.             else if ( nameExists(this.parameterName.value, this.parameters) )
  2315.             {
  2316.               alert(dwscripts.sprintf(MSG_Error_NameExists, this.parameterName.value, LABEL_Parameter));
  2317.               dwscripts.findDOMObject("parameterName").focus();
  2318.             }
  2319.             else
  2320.             {
  2321.               parameter.name = this.parameterName.value;
  2322.               this.parameters.set(parameter.name);
  2323.             }
  2324.           }
  2325.           else if (theItemName == "parameterDisplayName")
  2326.           {
  2327.             parameter.displayName = this.parameterDisplayName.value;
  2328.           }
  2329.           else if (theItemName == "parameterDescription")
  2330.           {
  2331.             parameter.description = this.parameterDescription.value;
  2332.           }
  2333.           else if (theItemName == "parameterType")
  2334.           {
  2335.             var newValue = this.parameterType.getValue();
  2336.             if (parameter.type != newValue)
  2337.             {
  2338.               parameter.type = newValue;
  2339.               // need to repick the value to work around a bug
  2340.               this.parameterType.pickValue(parameter.type);
  2341.             }
  2342.           }
  2343.           else if (theItemName == "parameterRequired")
  2344.           {
  2345.             parameter.required = this.parameterRequired.checked;
  2346.           }
  2347.           else if (theItemName == "parameterDefaultValue")
  2348.           {
  2349.             parameter.defaultValue = this.parameterDefaultValue.value;
  2350.           }
  2351.         }
  2352.         else
  2353.         {
  2354.           // disable form
  2355.           this.disable();
  2356.         }
  2357.       }
  2358.     }
  2359.     else
  2360.     {
  2361.       if (this.paramsEnabled)
  2362.       {
  2363.         this.parameters.setAll(new Array());
  2364.         this.parameters.disable();
  2365.         this.paramsEnabled = false;
  2366.         var plusButton = dwscripts.findDOMObject("btn_parameterPlus");
  2367.         plusButton.src = "../Shared/UltraDev/Images/PlusButtonDisabled.gif";
  2368.         var minusButton = dwscripts.findDOMObject("btn_parameterMinus");
  2369.         minusButton.src = "../Shared/UltraDev/Images/MinusButtonDisabled.gif";
  2370.       }
  2371.       this.disable();
  2372.     }
  2373.   }
  2374. }
  2375.  
  2376. //Called when another page is about to be shown, or finish() is called on
  2377. // the tabControl.  Use this call to perform any finishing tasks.
  2378. //
  2379. function ParametersPage_unload()
  2380. {
  2381.   //alert("unload() called " + this.tabLabel);
  2382.  
  2383.   // hack to make sure that controls disappear correctly
  2384.   T.obj.visibility = "hidden";
  2385.   T.obj.visibility = "visible";
  2386.   
  2387.   return true;
  2388. }
  2389.  
  2390. //Called when finish() is called on the tabControl.
  2391. // Use this call to perform any last minute page updates.
  2392. //
  2393. function ParametersPage_lastUnload()
  2394. {
  2395.   //alert("lastUnload() called " + this.tabLabel);
  2396.   return true;
  2397. }
  2398.  
  2399.  
  2400. function ParametersPage_enable()
  2401. {
  2402.   if (!this.pageIsEnabled)
  2403.   {
  2404.     this.pageIsEnabled = true;
  2405.     this.parameterName.removeAttribute("disabled");
  2406.     this.parameterDisplayName.removeAttribute("disabled");
  2407.     this.parameterDescription.removeAttribute("disabled");
  2408.     this.parameterType.enable();
  2409.     this.parameterRequired.removeAttribute("disabled");
  2410.     this.parameterDefaultValue.removeAttribute("disabled");
  2411.   }
  2412. }
  2413.  
  2414. function ParametersPage_disable()
  2415. {
  2416.   if (this.pageIsEnabled)
  2417.   {
  2418.     this.pageIsEnabled = false;
  2419.  
  2420.     // clear items
  2421.     this.parameterName.value = "";
  2422.     this.parameterDisplayName.value = "";
  2423.     this.parameterDescription.value = "";
  2424.     this.parameterType.pickValue("string");
  2425.     this.parameterRequired.checked = false;
  2426.     this.parameterDefaultValue.value = "";
  2427.  
  2428.     // now disable
  2429.     this.parameterName.setAttribute("disabled","true");
  2430.     this.parameterDisplayName.setAttribute("disabled","true");
  2431.     this.parameterDescription.setAttribute("disabled","true");
  2432.     this.parameterType.disable();
  2433.     this.parameterRequired.setAttribute("disabled","true");
  2434.     this.parameterDefaultValue.setAttribute("disabled","true");
  2435.   }
  2436. }
  2437.  
  2438. // =================================================================================================
  2439. //--------------------------------------------------------------------
  2440. // FUNCTION:
  2441. //   getParentCfcs
  2442. //
  2443. // DESCRIPTION:
  2444. //   Makes an http request to the CFCExplorer to return and array of
  2445. //     CFC names
  2446. //
  2447. // ARGUMENTS:
  2448. //   refreshCache - determines whether to get a fresh list of CFCs or not
  2449. //
  2450. // RETURNS:
  2451. //   array containing the name of available CFCs
  2452. //--------------------------------------------------------------------
  2453. function getParentCfcs( refreshCache ) {
  2454.   if (refreshCache == null ) {
  2455.     refreshCache = "no";
  2456.   }
  2457.   var root = new Array();
  2458.   var cfcNames =  new Array();
  2459.   // first item will be "" so that it doesn't look like a parent is automatically selected
  2460.   cfcNames[0] = "";
  2461.   var cfcNamesLen = cfcNames.length;
  2462.   var wddxParentCfcs = "";
  2463.  
  2464.   var introspectionURL = getIntrospectionUrl();
  2465.   if (introspectionURL != "")
  2466.   {
  2467.  
  2468.     MM.setBusyCursor(); 
  2469.     var pwdBase64 = MMToBase64(MMDB.getRDSUserName() + ":" + MMDB.getRDSPassword());
  2470.     var strHeader = "Authorization-MX: Basic " + pwdBase64 + "\r\n";
  2471.     var httpReply = MMHttp.postText(introspectionURL + "?method=getcfcs&refreshcache=" + refreshCache, "", "", strHeader); 
  2472.  
  2473.     // only process WDDX if reply successful, else just return new Array()
  2474.     if (httpReply.statusCode == 200) {
  2475.       wddxParentCfcs = httpReply.data;
  2476.       //alert("raw WDDX packet\n\n" + wddxParentCfcs);
  2477.       var des = new WddxDeserializer();
  2478.       root = des.deserialize(wddxParentCfcs);
  2479.         // this happens to be null sometimes, ignore that it's null and just bring up the dialog
  2480.         if( root != null ) {
  2481.         for( var i=0; i<root.length; i++ ) {
  2482.           cfcNames[i+cfcNamesLen] = root[i].NAME;
  2483.         }
  2484.       }  
  2485.       // sorting and empty array seems to make it null and was throwing errors in  ListControlClass's setAll
  2486.       if( cfcNames.length >  0 ) {
  2487.         cfcNames = cfcNames.sort();
  2488.       }
  2489.     }
  2490.     MM.clearBusyCursor();       
  2491.   } else {
  2492.     //alert('no url prefix???');
  2493.   }
  2494.   return cfcNames;
  2495. }
  2496.  
  2497. //--------------------------------------------------------------------
  2498. // FUNCTION:
  2499. //   repopulateCompParent
  2500. //
  2501. // DESCRIPTION:
  2502. //   - calls methods to retrieve a fresh the list of available components
  2503. //
  2504. // ARGUMENTS:
  2505. //   NONE
  2506. //
  2507. // RETURNS:
  2508. //   NONE
  2509. //--------------------------------------------------------------------
  2510. function repopulateCompParent() {
  2511.     LABEL_PARENT_CFCS = getParentCfcs("yes");
  2512.     T.getPageObject("componentSection").compParent.setAll(LABEL_PARENT_CFCS,LABEL_PARENT_CFCS);
  2513. }
  2514.  
  2515. //--------------------------------------------------------------------
  2516. // FUNCTION:
  2517. //   getCfcRoots
  2518. //
  2519. // DESCRIPTION:
  2520. //   Makes an http request to the CFCExplorer to return and array of
  2521. //     CFC names
  2522. //
  2523. // ARGUMENTS:
  2524. //   refreshCache - determines whether to get a fresh list of CFCs or not
  2525. //
  2526. // RETURNS:
  2527. //   array containing the name of available CFCs
  2528. //--------------------------------------------------------------------
  2529. function getCfcRoots( refreshCache ) {
  2530.   if (refreshCache == null ) {
  2531.     refreshCache = "no";
  2532.   }
  2533.   var root = new Array();
  2534.   var cfcRoots =  new Array();
  2535.   // first item will be "" so that it doesn't look like a parent is automatically selected
  2536.   cfcRoots[0] = "";
  2537.   var cfcRootsLen = cfcRoots.length;
  2538.   var wddxCfcRoots = "";
  2539.  
  2540.   var introspectionURL = getIntrospectionUrl();
  2541.   if (introspectionURL != "")
  2542.   {
  2543.     MM.setBusyCursor(); 
  2544.     var pwdBase64 = MMToBase64(MMDB.getRDSUserName() + ":" + MMDB.getRDSPassword());
  2545.     var strHeader = "Authorization-MX: Basic " + pwdBase64 + "\r\n";
  2546.     var httpReply = MMHttp.postText(introspectionURL + "?method=getcomponentroots&refreshcache=" + refreshCache, "", "", strHeader); 
  2547.  
  2548.     // only process WDDX if reply successful, else just return new Array()
  2549.     if (httpReply.statusCode == 200) {
  2550.       wddxCfcRoots = httpReply.data;
  2551.       //alert("raw WDDX packet\n\n" + wddxCfcRoots);
  2552.       var des = new WddxDeserializer();
  2553.       root = des.deserialize(wddxCfcRoots);
  2554.       // this happens to be null sometimes, ignore that it's null and just bring up the dialog
  2555.         if( root != null ) {
  2556.         for( var i=0; i<root.length; i++ ) {
  2557.           cfcRoots[i+cfcRootsLen] = root[i].PHYSICALPATH;
  2558.         }
  2559.       }    
  2560.       // sorting and empty array seems to make it null and was throwing errors in  ListControlClass's setAll
  2561.       if( cfcRoots.length >  0 ) {
  2562.         cfcRoots = cfcRoots.sort();
  2563.       }
  2564.     }
  2565.     MM.clearBusyCursor();       
  2566.   } else {
  2567.     //alert('no url prefix???');
  2568.   }
  2569.   return cfcRoots;
  2570. }
  2571.     
  2572. function nameExists(name, listToSearch) {
  2573.   if( name != null ) {
  2574.     for ( var i=0; i<listToSearch.getLen(); i++ ) {
  2575.       // need to check that it's not being compared against the current index that it's 
  2576.       // trying to update! should the user not change the name
  2577.       if( name == listToSearch.get(i) && i != listToSearch.getIndex()) {
  2578.         return true;
  2579.       }
  2580.     }
  2581.   }
  2582.   return false;
  2583. }
  2584.  
  2585.